<?php 
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/entite/compte/CompteEntite.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/persistence/compte/CompteDAO.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/entite/VO.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/entite/compte/CompteService.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/uc/gerercompte/CompteVO.php';
	include_once $_SERVER["DOCUMENT_ROOT"].'/service/uc/gerercompte/RoleVO.php';
	
	
	class GererCompteVOAssembler{
		public static function createRoleVO(RoleEntite $role) {
			$roleVO = new RoleVO();
			$roleVO->id = $role->id;
			$roleVO->code = $role->code;
			$roleVO->libelle = $role->libelle;
			return $roleVO;
		}
		
		public static function createRoleVOMinimaliste($idRole) {
			$roleVO = new RoleVO();
			$roleVO->id = $idRole;
			return $roleVO;
		}
		
		
		
		public static function createCompteVO(CompteEntite $compte) {
			$compteVO = new CompteVO();
			$compteVO->id = $compte->id;
			$compteVO->login = $compte->login;
			$compteVO->motDePasse = $compte->motDePasse;
			$compteVO->listeRoleVO = Array();
			$listeRole = CompteService::getListeRoleAssocieACompte($compte->id);
			foreach ($listeRole as $role) {
				$roleVO = GererCompteVOAssembler::createRoleVO($role);
				$compteVO->listeRoleVO[] = $roleVO;
			}
			return $compteVO;
		}
		
		public static function getEntity(CompteVO $compteVO) {
			if ($compteVO->id == VO::getUnpersistedId()) {
				$compte = new CompteEntite();
			} else {
				$compte = CompteDAO::getCompteByID($compteVO->id);
			}
			$compte->id = $compteVO->id;
			$compte->login = $compteVO->login;
			$compte->motDePasse = $compteVO->motDePasse;
			return $compte;
		}
		
		public static function createListeCompteVO($listeCompteEntite) {
			$listeCompteVO = Array();
			foreach ($listeCompteEntite as $compteEntite) {
				$listeCompteVO[] = GererCompteVOAssembler::createCompteVO($compteEntite);
			}
			return $listeCompteVO;
		}
	}

?>